#include<iostream>
using namespace std;
const int N = 10;
int n, m;
int st[N][N];
int x, y;
int dx[] = { 1,1,2,2,-1,-1,-2,-2 };
int dy[] = { 2,-2,1,-1,2,-2,1,-1 };
int dfs(int x, int y,int sum)	
{
	if (sum == n * m) {
		return 1;
	}
	st[x][y] = 1;
	int ans = 0;
	for (int i = 0; i < 8; i++) {
		int a = dx[i] + x;
		int b = dy[i] + y;
		if (a < 0 || a >= n || b < 0 || b >= m) {
			continue;
		}
		if (st[a][b])continue;
		ans += dfs(a, b, sum + 1);
	}
	st[x][y] = 0;
	return ans;
}
int main()
{
	int t;
	cin >> t;
	while (t--) {
		cin >> n >> m >> x >> y;	
		cout << dfs(x, y, 1) << endl;
	}
	
	return 0;
}